package com.example.review.ParseData;

import android.util.Log;

import org.json.JSONArray;
import org.json.JSONObject;

public class ParseJSONWithJSONObject {

//[
//    {
//        "id":"5",
//            "version":"5.5",
//            "name":"Clash of Clans"
//    },
//    {
//        "id":"6",
//            "version":"7.0",
//            "name":"Boom Beach"
//    },
//    {
//        "id":"7",
//            "version":"3.5",
//            "name":"Clash Royale"
//    }
//]

    private void parseJSONWithJSONObject(String jsonData) {
        try {
            JSONArray jsonArray = new JSONArray(jsonData);
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                String id = jsonObject.getString("id");
                String name = jsonObject.getString("name");
                String version = jsonObject.getString("version");
                Log.d("MainActivity", "id is " + id);
                Log.d("MainActivity", "name is " + name);
                Log.d("MainActivity", "version is " + version);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}